package core;

import java.awt.Point;

/**
 * Represent's a <code>Card</code>'s spatial location, consisting of a 2D point
 * and a rotation (specified in radians)
 */
public class Location
{
	/**
	 * Construct a new spatial location at point (0,0) with no rotation
	 */
	public Location() {
		this(0, 0, 0d);
	}

	/**
	 * Construct a new spatial location at the given point with no rotation
	 */
	public Location(Point p) {
		this(p.x, p.y);
	}

	/**
	 * Construct a new spatial location at the given (x, y) point with no rotation
	 */
	public Location(int x, int y) {
		this(x, y, 0d);
	}

	/**
	 * Construct a new spatial location at the given point with the given rotation 
	 */
	public Location(Point p, double rotation) {
		this(p.x, p.y, rotation);
	}

	/**
	 * Construct a new spatial location at the given (x, y) point with the given rotation 
	 */
	public Location(int x, int y, double rotation) {
		this.x = x;
		this.y = y;
		this.rotation = rotation;
	}

	/**
	 * Get the rotation for this location (in radians)
	 */
	public double getRotation() {
		return rotation;
	}

	/**
	 * Set the rotation for this location (in radians)
	 */
	public void setRotation(double rotation) {
		this.rotation = rotation;
	}

	/**
	 * Get the x position for this location
	 */
	public int getX() {
		return x;
	}

	/**
	 * Set the x position for this location
	 */
	public void setX(int x) {
		this.x = x;
	}

	/**
	 * Get the y position for this location
	 */
	public int getY() {
		return y;
	}

	/**
	 * Set the y position for this location
	 */
	public void setY(int y) {
		this.y = y;
	}

	/**
	 * Get the position for this location as a Point
	 */
	public Point getPosition() {
		return new Point(x,y);
	}

	public boolean equals(Location l) {
		return l != null && x == l.x && y == l.y && rotation == l.rotation;
	}

	public String toString() {
		return "(" + x + "," + y + "," + rotation + ")";
	}

	private int x;
	private int y;
	private double rotation;
}